﻿using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


namespace YFrameWork.RunTime
{
    /// <summary>
    /// 打开UI界面动画移动X轴
    /// </summary>
    public class UIOpenAnimMoveX : UIOpenAnimationBase
    {
        private Transform mTargetTran;
        private float mTargetXPos;
        private float mDelayed;
        public UIOpenAnimMoveX(Transform transform,float _targetPos,float _delayed = 0.3f)
        {
            mTargetXPos = _targetPos;
            mTargetTran = transform;
            mDelayed = _delayed;
        }
        public override void Open()
        {
            mTargetTran.DOLocalMoveX(mTargetXPos, mDelayed);
        }
    }
    /// <summary>
    /// 打开UI界面动画移动X轴
    /// </summary>
    public class UICloseAnimMoveX : UICloseAnimationBase
    {
        private Transform mTargetTran;
        private float mTargetXPos;
        private float mDelayed;
        public UICloseAnimMoveX(Transform transform, float _targetPos, float _delayed = 0.3f)
        {
            mTargetXPos = _targetPos;
            mTargetTran = transform;
            mDelayed = _delayed;
        }
        public override void Close(Action act)
        {
            Tweener tw = mTargetTran.DOLocalMoveX(mTargetXPos, mDelayed);
            tw.OnComplete(() => { act?.Invoke(); });
        }
    }
}